import useRequest from "@/utils/request";

const request = useRequest({});
// 获取场地分页数据
export function listSite(params: any) {
  return request.get("/cj-stadium/sys/site/page", {
    params: params,
  });
}

// 获取场地分页数据
export function treeList(params: any) {
  return request.get("/cj-stadium/sys/site/treePage", {
    params: params,
  });
}

export function updateSite(entity: any) {
  return request.post("/cj-stadium/sys/site/base/update", entity);
}

export function updateSiteState(entity: any) {
  return request.post("/cj-stadium/sys/site/base/updateState", entity);
}

export function batchToggleStatus(entity: any) {
  return request.post("/cj-stadium/sys/site/base/batchToggleStatus", entity);
}

export function quickSearchStadium(params: any) {
  return request.get("/cj-stadium/sys/stadium/stadium/quickSearch", {
    params: params,
  });
}

/**
 * 新增多条场地信息
 * @param {Object} entity - 场馆实体对象
 */
export function createSite(entity: any) {
  return request.post("/cj-stadium/sys/site/base/addList", entity);
}

//  根据场馆id  获取所有场地的列表
export function getSitesByStadiumId(params: any) {
  return request.get(`/cj-stadium/sys/site/getByStadiumId`, {
    params,
  });
}

export function getBusinessTimeById(params: any) {
  return request.get("/cj-stadium/sys/site/base/getBusinessTimeById", {
    params: params,
  });
}

// 根据场地id 获取所有的图片
export function getFileBySiteId(id: string | number) {
  return request.get(`/cj-stadium/sys/site/getFileBySiteId/${id}`);
}

//跟场地id以及场地类型查询价格列表
export function getPriceListByIdAndType(params: any) {
  return request.get("/cj-stadium/sys/site/base/getSitePriceListByIdAndType", {
    params: params,
  });
}

// 根据场地id 获取所有的图片
export function getFileByStadiumIdAndType(id: string | number, params: any) {
  return request.get(`/cj-stadium/sys/site/getFileByStadiumIdAndType/${id}`, {
    params: params,
  });
}

// 根据场地id 获取所有的定价
export function getPriceBySiteId(id: string | number) {
  return request.get(`/cj-stadium/sys/site/getPriceBySiteId/${id}`);
}

/**
 * 场地订场信息保存
 */
export function saveBulletin(entity: any) {
  return request.post("/cj-stadium/sys/bulletin/save", entity);
}

/**
 * 场地订场信息查询
 */
export function getBulletinListBySite(entity: any) {
  return request.post("/cj-stadium/sys/bulletin/list", entity);
}

/**
 * 取消预定场次
 */
export function cancelBulletin(entity: any) {
  return request.post("/cj-stadium/sys/bulletin/cancel", entity);
}

/**
 * 修改预定场次价格
 */
export function updateBulletin(entity: any) {
  return request.post("/cj-stadium/sys/bulletin/update", entity);
}

// Id 删除场馆 定价
export function deletePriceById(id: string | number) {
  return request.get(`/cj-stadium/sys/site/deletePriceById/${id}`);
}

// 散客订场
export function updateOrderType(params: any) {
  return request.post(`/cj-stadium/sys/bulletin/updateOrderType/`, params);
}

// 散客订场
export function getOrderListByTime(params: any) {
  return request.post(`/cj-stadium/sys/bulletin/getOrderListByTime/`, params);
}

// 核销验证码
export function writeCode(params: any) {
  return request.get(`/cj-stadium/sys/bulletin/writeCode/`, {
    params,
  });
}

// 场地审核列表
export function getApprovalSiteList(params: any) {
  return request.get(`/cj-stadium/sys/site/getApprovalSiteList`, {
    params,
  });
}
// 场地审核统计
export function getApprovalSiteCount(params: any) {
  return request.get(`/cj-stadium/sys/site/getApprovalSiteCount`, {
    params,
  });
}

// 场地审核详情
export function getApprovalSiteDetail(params: any) {
  return request.get(`/cj-stadium/sys/site/getApprovalSiteDetail`, {
    params,
  });
}

// 场地-根据场馆id审核场地
export function approvalSiteByStadiumId(params: any) {
  return request.get(`/cj-stadium/sys/site/approvalSiteByStadiumId`, {
    params,
  });
}

// 删除场地审核记录
export function delSiteByStadiumId(params: any) {
  return request.get(`/cj-stadium/sys/site/delSiteByStadiumId`, {
    params,
  });
}

// 场地-根据场馆id查询类型以及场地列表
export function selectSiteListBySiteType(params: any) {
  return request.get(`/cj-stadium/sys/stadiumAndSite/stadium/selectSiteListBySiteType`, {
    params,
  });
}

// 场地-根据场馆id查询场地类型列表
export function getSiteTypeListByStadiumId(params: any) {
  return request.get(`/cj-stadium/sys/site/getSiteTypeListByStadiumId`, {
    params,
  });
}

// 场地信息新增场地以及价格
export function saveSiteAndPrice(data: any) {
  return request.post(`/cj-stadium/sys/stadiumAndSite/stadium/saveSiteAndPrice`, data);
}

// 场地-删除单条场地
export function deleteSite(siteId: string | number) {
  return request.get(`/cj-stadium/sys/site/deleteSiteById`, {
    params: {
      siteId,
    },
  });
}

// 场地-启用/停用单条场地
export function editSiteEnable(params: any) {
  return request.get(`/cj-stadium/sys/site/editSiteEnable`, {
    params,
  });
}

// 场地-提交审核
export function submitSiteApproval(stadiumId: string | number) {
  return request.get(`/cj-stadium/sys/stadiumAndSite/stadium/submitSiteApproval`, {
    params: { stadiumId },
  });
}

// 场地信息根据场馆id以及类型删除场地
export function delSiteByStadiumIdAndType(params: any) {
  return request.get(`/cj-stadium/sys/stadiumAndSite/site/delSiteByStadiumIdAndType`, {
    params,
  });
}

// pc场次-根据日期以及场地类型查询预约列表
export function getBulletinListByDateType(params: any) {
  return request.get(`/cj-stadium/sys/bulletin/getBulletinListByDateAndSiteType`, {
    params,
  });
}

// 订单-看板订单详情
export function getOrderDetailToBoard(params: any) {
  return request.get(`/cj-stadium/sys/order/getOrderDetailToBoard`, {
    params,
  });
}

// pc场次-场次详情查询
export function getBulletinDetail(params: any) {
  return request.get(`/cj-stadium/sys/bulletin/getBulletinDetail`, {
    params,
  });
}

// 订单-查询场地散客订单列表
export function getOrderListByStadiumIdAndSite(params: any) {
  return request.get(`/cj-stadium/sys/order/getOrderListByStadiumIdAndSite`, {
    params,
  });
}

// 场地-登录用户是否展示散客场地配置
export function updateShowSite(params: any) {
  return request.get(`/cj-stadium/sys/site/updateShowSite`, {
    params,
  });
}

// 场地-根据场馆id以及类型查询场地列表-价格模板
export function getSiteListToTemplate(params: any) {
  return request.get(`/cj-stadium/sys/site/getSiteListToTemplate`, {
    params,
  });
}